package com.merelyb.data.service.service.service.account;

import com.merelyb.data.service.common.MultiDataSourceContextHolder;
import com.merelyb.data.service.service.mybatis.bean.account.AccountInfo;
import com.merelyb.data.service.service.mybatis.dao.account.AccountInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by LiM on 2017/12/11.
 */
@Service
public class AccountInfoService {
    @Autowired
    AccountInfoDao accountInfoDao;

    /**
     * 查询数据
     *
     * @param accountInfo
     * @return
     * @throws Exception
     */
    public List<AccountInfo> queryAllList(AccountInfo accountInfo) throws Exception {
        return accountInfoDao.queryAllList(accountInfo, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 分页查询数据
     *
     * @param accountInfo
     * @return
     */
    public List<AccountInfo> queryListByLimit(AccountInfo accountInfo) {
        return accountInfoDao.queryListByLimit(accountInfo, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 新增单条数据
     *
     * @param accountInfo
     * @throws Exception
     */
    public void addData(AccountInfo accountInfo) throws Exception {
        accountInfoDao.addData(accountInfo, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 批量新增数据
     *
     * @param accountInfoList
     * @throws Exception
     */
    public void addData(List<AccountInfo> accountInfoList) throws Exception {
        accountInfoDao.addData(accountInfoList, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 更新数据
     *
     * @param accountInfo
     * @throws Exception
     */
    public void updateData(AccountInfo accountInfo) throws Exception {
        accountInfoDao.updateData(accountInfo, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 更新数据状态
     *
     * @param accountInfo
     * @throws Exception
     */
    public void deleteData(AccountInfo accountInfo) throws Exception {
        accountInfoDao.deleteData(accountInfo, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 统计数量
     *
     * @param accountInfo
     * @return
     */
    public int getCount(AccountInfo accountInfo) {
        return accountInfoDao.getCount(accountInfo, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }
}
